package com.chinawayltd.ews.sample.manager.redis.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import com.chinawayltd.ews.sample.manager.redis.DriverManager;

/**
 * @program: greeProject-interfaceManager
 * @description 首页和监控大屏数据缓存
 * @author: chenxin
 * @create: 2018年5月22日 上午12:42:35
 */
@Service
public class DriverManagerRedisImpl implements DriverManager {

	private final String MAIN = "DRIVER:";
    private final String DRIVER_WORK_DATA = "DRIVER_WORK_DATA";
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

	public void setTokenDriver(String key, String content) throws Exception{
		if(StringUtils.isBlank(content)){
            throw new NullPointerException("data must be not blank!");
        }
		stringRedisTemplate.opsForValue().set(key, content);
	}
	public String getTokenDriverByKey(String key) {
		return stringRedisTemplate.opsForValue().get(key);
	}

	public void deleteTokenDriver(String key) {
		stringRedisTemplate.delete(key);
	}
	
}
